<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('订单详细')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-order-edit" th:object="${shopUserOrder}">
            <h4 class="form-header h4">订单信息</h4>
            <div class="form-group">
                <label class="col-sm-3 control-label">管理员后台备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control">[[*{remark}]]</textarea>
                    <a href="javascript:void(0)" onclick="doRemark()">提交</a>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">交易状态：</label>
                <div class="col-sm-8">
                    <div class="radio-box">
                        <input type="radio" id="tradeStatus_1" name="tradeStatus" value="1" th:checked="*{tradeStatus == 1}">
                        <label th:for="tradeStatus_1" th:text="交易中"></label>
                    </div>
                    <div class="radio-box">
                        <input type="radio" id="tradeStatus_2" name="tradeStatus" value="2" th:checked="*{tradeStatus == 2}">
                        <label th:for="tradeStatus_2" th:text="交易完成"></label>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">订单号：</label>
                    <div class="col-sm-8">
                        <input name="ns" th:field="*{ns}" class="form-control" type="text" readonly>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">商品的类型：</label>
                    <div class="col-sm-8">
                        <label th:if="*{productType == 1}">商品</label>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">商品的名称：</label>
                    <div class="col-sm-8">
                        <input name="productTitle" th:field="*{productTitle}" class="form-control" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">商品描述：</label>
                    <div class="col-sm-8">
                        <textarea name="productSummary" class="form-control">[[*{productSummary}]]</textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">购买人昵称：</label>
                    <div class="col-sm-8">
                        <input name="buyerNickname" th:field="*{buyerNickname}" class="form-control" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">用户留言：</label>
                    <div class="col-sm-8">
                        <textarea name="buyerMsg" class="form-control">[[*{buyerMsg}]]</textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">订单总金额：</label>
                    <div class="col-sm-8">
                        <input name="orderTotalAmount" th:field="*{orderTotalAmount}" class="form-control" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">订单的真实金额：</label>
                    <div class="col-sm-8">
                        <input name="orderRealAmount" th:field="*{orderRealAmount}" class="form-control" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">优惠码：</label>
                    <div class="col-sm-8">
                        <input name="couponCode" th:field="*{couponCode}" class="form-control" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">优惠金额：</label>
                    <div class="col-sm-8">
                        <input name="couponAmount" th:field="*{couponAmount}" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
            <div class="form-group">    
                <label class="col-sm-3 control-label">支付状态：</label>
                <div class="col-sm-8">
                    <div class="radio-box">
                        <input type="radio" id="payStatus_1" name="payStatus" value="1" th:checked="*{payStatus == 1}">
                        <label th:for="payStatus_1" th:text="未付款"></label>
                    </div>
                    <div class="radio-box">
                        <input type="radio" id="payStatus_2" name="payStatus" value="2" th:checked="*{payStatus == 2}">
                        <label th:for="payStatus_2" th:text="线下付款完成"></label>
                    </div>
                    <div class="radio-box">
                        <input type="radio" id="payStatus_3" name="payStatus" value="3" th:checked="*{payStatus == 3}">
                        <label th:for="payStatus_3" th:text="微信"></label>
                    </div>
                </div>
            </div>

            <div class="form-group">    
                <label class="col-sm-3 control-label">支付成功的金额：</label>
                <div class="col-sm-8">
                    <input name="paySuccessAmount" th:field="*{paySuccessAmount}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">支付时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="paySuccessTime" th:value="${#dates.format(shopUserOrder.paySuccessTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" readonly>
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">支付证明：</label>
                <div class="col-sm-8">
                    <img src="*{paySuccessProof}" width="400" th:if="*{paySuccessProof != null}">

                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 手动入账时需要截图</span>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">支付备注：</label>
                <div class="col-sm-8">
                    <input name="paySuccessRemarks" th:field="*{paySuccessRemarks}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">支付记录：</label>
                <div class="col-sm-8">
                    <input name="paymentId" th:field="*{paymentId}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">第三方订单号：</label>
                <div class="col-sm-8">
                    <input name="paymentOuterId" th:field="*{paymentOuterId}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">第三方支付用户openId：</label>
                <div class="col-sm-8">
                    <input name="paymentOuterUser" th:field="*{paymentOuterUser}" class="form-control" type="text">
                </div>
            </div>

            <div class="form-group">    
                <label class="col-sm-3 control-label">发货类型：</label>
                <div class="col-sm-8">
                    <div class="radio-box">
                        <input type="radio" id="deliveryType1" name="deliveryType" value="1" th:checked="*{deliveryType ==1}">
                        <label th:for="deliveryType1" th:text="邮寄"></label>
                    </div>
                    <div class="radio-box">
                        <input type="radio" id="deliveryType2" name="deliveryType" value="2" th:checked="*{deliveryType ==2}">
                        <label th:for="deliveryType2" th:text="自提"></label>
                    </div>
                    <div class="radio-box">
                        <input type="radio" id="deliveryType3" name="deliveryType" value="3" th:checked="*{deliveryType ==3}">
                        <label th:for="deliveryType3" th:text="配送"></label>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">发货状态：</label>
                <div class="col-sm-8">
                    <div class="radio-box">
                        <input type="radio" id="deliveryStatus1" name="deliveryStatus" value="1" th:checked="*{deliveryStatus ==1}">
                        <label th:for="deliveryStatus1" th:text="未发货"></label>
                    </div>
                    <div class="radio-box">
                        <input type="radio" id="deliveryStatus2" name="deliveryStatus" value="2" th:checked="*{deliveryStatus ==2}">
                        <label th:for="deliveryStatus2" th:text="配送中"></label>
                    </div>
                    <div class="radio-box">
                        <input type="radio" id="deliveryStatus3" name="deliveryStatus" value="3" th:checked="*{deliveryStatus ==3}">
                        <label th:for="deliveryStatus3" th:text="配送完成"></label>
                    </div>
                </div>
            </div>
        </div>

        <div class="col-sm-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h5 class="panel-title">
                        <a data-toggle="collapse" data-parent="#version" href="#user-address">用户收货地址</a><code class="pull-right">点击可收起</code>
                    </h5>
                </div>
                <div id="user-address" class="panel-collapse collapse in">
                    <div class="panel-body">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">收货人地址：</label>
                            <div class="col-sm-8">
                                <input name="deliveryAddrUsername" th:field="*{deliveryAddrUsername}" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">收货人手机号：</label>
                            <div class="col-sm-8">
                                <input name="deliveryAddrMobile" th:field="*{deliveryAddrMobile}" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">收件人省：</label>
                            <div class="col-sm-8">
                                <input name="deliveryAddrProvince" th:field="*{deliveryAddrProvince}" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">收件人的城市：</label>
                            <div class="col-sm-8">
                                <input name="deliveryAddrCity" th:field="*{deliveryAddrCity}" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">收件人的区：</label>
                            <div class="col-sm-8">
                                <input name="deliveryAddrDistrict" th:field="*{deliveryAddrDistrict}" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">收件人的详细地址：</label>
                            <div class="col-sm-8">
                                <input name="deliveryAddrDetail" th:field="*{deliveryAddrDetail}" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">收件人地址邮政编码：</label>
                            <div class="col-sm-8">
                                <input name="deliveryAddrZipcode" th:field="*{deliveryAddrZipcode}" class="form-control" type="text">
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
        </form>

        <h4 class="form-header h4">订单明细信息</h4>
        <div class="table-responsive m-t">
            <table class="table invoice-table">
                <thead>
                <tr>
                    <th>清单</th>
                    <th>数量</th>
                    <th>单价</th>
                    <th>其他费用</th>
                    <th>总价</th>
                    <th>状态</th>
                    <th>退款单号</th>
                    <th>退款金额</th>
                </tr>
                </thead>
                <tbody>
                <tr th:each="item : ${shopUserOrder.shopUserOrderItemList}">
                    <td>
                        <div><strong th:text="${item.productTitle}"></strong>
                        </div>
                    </td>
                    <td th:text="${item.productCount}">1</td>
                    <td th:text="${item.productPrice}">&yen;26.00</td>
                    <td th:text="${item.otherCost}">&yen;1.20</td>
                    <td th:text="${item.totalAmount}">&yen;31,98</td>

                    <td th:text="${item.status}"></td>
                    <td th:text="${item.refundNo}"></td>
                    <td th:text="${item.refundAmount}"></td>
                </tr>

                </tbody>
            </table>
        </div>
        <!-- /table-responsive -->

        <table class="table invoice-total">
            <tbody>
            <tr>
                <td><strong>总价：</strong>
                </td>
                <td th:text="${shopUserOrder.orderTotalAmount}">&yen;0.00</td>
            </tr>
            <tr>
                <td><strong>优惠金额：</strong>
                </td>
                <td th:text="${shopUserOrder.couponAmount}">&yen;0.00</td>
            </tr>
            <tr>
                <td><strong>总计</strong>
                </td>
                <td th:text="${shopUserOrder.orderRealAmount}">&yen;0.00</td>
            </tr>
            </tbody>
        </table>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "shop/order";
        var id = [[${shopUserOrder.id}]];

        function submitHandler() {

        }

        function doRemark() {
            var msg = $("textarea[name='remark']").val();
            if(msg == undefined || msg ==""){
                $.modal.alertWarning("请填写备注！");
                return;
            }

            var data = {'id': id, 'remark':msg};
            reqSubmit(prefix + "/edit/remark",data)
        }


        function reqSubmit(url, data){
            $.ajax({
                url: url,
                type: 'post',
                cache: false,
                data: data,
                dataType: "json",
                success: function(result) {
                    if(result.code == 0) {
                        $.modal.alertWarning("备注成功");
                    } else {
                        $.modal.alertError("备注失败");
                    }
                }
            });
        }
    </script>
</body>
</html>